package com.ljb.retrofit_demo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.ljb.http.logger.Logger;
import com.ljb.http.retrofit.request.RetrofitRequest;
import com.ljb.http.retrofit.request.RetrofitResponse;
import com.ljb.retrofit_demo.bean.WeatherBean;
import com.ljb.retrofit_demo.service.IRequest;

import retrofit2.Call;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        load();
    }

    private void load() {
        Call<WeatherBean> call = RetrofitRequest.getInstance().create(IRequest.class).getWeather("rot2enzrehaztkdk", "beijing");
        RetrofitRequest.getInstance().asyncNetWork(MainActivity.class, URl.REQUEST_TEXT, call, new RetrofitResponse<WeatherBean>() {
            @Override
            public void onDataReady(WeatherBean response) {
                Logger.d(response.results.get(0).last_update);
            }

            @Override
            public void onDataError(int requestCode, int responseCode, String message) {

            }
        });

    }
}
